package com.chinamobile.push

import android.app.Activity
import android.os.Bundle
import android.util.Log
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.facade.annotation.Route
import com.chinamobile.push.config.PassPath
import com.cmcc.shared.utils.clickWithTrigger
import com.chinamobile.push.databinding.ActivityLoginBinding
import com.cmcc.shared.BaseActivity
import com.cmcc.shared.SdkManager

@Route(path = PassPath.APP_LOGIN)
class LoginActivity : BaseActivity() {

    private lateinit var binding: ActivityLoginBinding

    private var myLinkToken: String = ""


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding =
            DataBindingUtil.setContentView(this, R.layout.activity_login)

        initEvent()
    }


    override fun initialize(savedInstanceState: Bundle?) {

    }

    private fun initEvent() {

        binding.driver0.clickWithTrigger {
            //            myLinkToken = "13000000001"
            myLinkToken = "15000000002"
            userLogin()
        }
        binding.passenger0.clickWithTrigger {
            myLinkToken = "15000000001"
            userLogin()
        }

        binding.driver1.clickWithTrigger {
            //            myLinkToken = "13000000001"
            myLinkToken = "13800000007"
            userLogin()
        }
        binding.passenger1.clickWithTrigger {
            myLinkToken = "13000000004"
            userLogin()
        }

        binding.driver2.clickWithTrigger {
            //            myLinkToken = "13000000002"
            myLinkToken = "13800000008"
            userLogin()
        }

        binding.passenger2.clickWithTrigger {
            myLinkToken = "13000000005"
            userLogin()
        }

        binding.driver3.clickWithTrigger {
            //            myLinkToken = "13000000003"
            myLinkToken = "13800000009"
            userLogin()
        }

        binding.passenger3.clickWithTrigger {
            myLinkToken = "13800000006"
            userLogin()
        }

        binding.btnOne.clickWithTrigger {
            myLinkToken = "13800000010"
            userLogin()
        }

        binding.btnTwo.clickWithTrigger {
                myLinkToken = "13000000021"
            userLogin()
        }
//       const val LANGUAGE_ENG = 0//英文
//       const val LANGUAGE_ZH_CN = 1//简体
//       const val LANGUAGE_ZH_TW = 2//繁体

        var type = 1//

        binding.language.clickWithTrigger {
            val value = type % 3;

            Log.e("LoginActivity","value"+value+":type = "+type)
            if (value == 0) {
                binding.language.text = "简体"
                SdkManager.setLanguage(SdkManager.LANGUAGE_ZH_CN)
            }
            if (value == 1) {
                binding.language.text = "繁體"
                SdkManager.setLanguage(SdkManager.LANGUAGE_ZH_TW)
            }
            if (value == 2) {
                binding.language.text = "英文"
                SdkManager.setLanguage(SdkManager.LANGUAGE_ENG)
            }
            type = type + 1;

        }
    }


    private fun userLogin() {
        SdkManager.setMyLinkToken(myLinkToken)
        setResult(Activity.RESULT_OK)
        finish()
    }

}
